home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpack / demopack.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  8.7 KB  |  354 lines

  1. unit DemoPack;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Grids, StdCtrls, Buttons, ExtCtrls, TabNotBk
  8.   , UserInfo
  9.   , UserNetw
  10.   , UserBDE
  11.   , UserWin
  12.   , Splash
  13.   , Bitbox
  14.   , Resizer
  15.   , Shells
  16.   , Restorer
  17.   , Debugctl
  18.   , ErrorMsg
  19.   , OkCore
  20.   , Working
  21.   , LoginDlg
  22.   , IniLink
  23.   , Toolbar
  24.   , Invoice
  25.   , About
  26.   , ToolProc
  27.   , DocProps;
  28.  
  29. type
  30.   TtPack2Form = class(TForm)
  31.     TabbedNotebook1: TTabbedNotebook;
  32.     WindowsGrid: TStringGrid;
  33.     NovellGrid: TStringGrid;
  34.     BDEGrid: TStringGrid;
  35.     Memo1: TMemo;
  36.     Button1: TButton;
  37.     Label1: TLabel;
  38.     Label2: TLabel;
  39.     Label3: TLabel;
  40.     Edit1: TEdit;
  41.     Label4: TLabel;
  42.     Button2: TButton;
  43.     Panel1: TPanel;
  44.     SpeedButton1: TSpeedButton;
  45.     Edit2: TEdit;
  46.     Label5: TLabel;
  47.     Label6: TLabel;
  48.     Edit3: TEdit;
  49.     Button3: TButton;
  50.     Label7: TLabel;
  51.     Edit4: TEdit;
  52.     Button4: TButton;
  53.     Label8: TLabel;
  54.     StatusBar2: TStatusBar;
  55.     MessagePanel1: TMessagePanel;
  56.     StatusPanel1: TStatusPanel;
  57.     WindowsUserInfo1: TWindowsUserInfo;
  58.     NetWareUserInfo1: TNetWareUserInfo;
  59.     BDEUserInfo1: TBDEUserInfo;
  60.     SplashScreen1: TSplashScreen;
  61.     IniFileLink1: TIniFileLink;
  62.     Button5: TButton;
  63.     LoginDialog1: TLoginDialog;
  64.     Button6: TButton;
  65.     WorkingMsg1: TWorkingMsg;
  66.     Button7: TButton;
  67.     ErrorDialog1: TErrorDialog;
  68.     Button8: TButton;
  69.     DebugControl1: TDebugControl;
  70.     FormRestorer1: TFormRestorer;
  71.     ReSizerPanel1: TReSizerPanel;
  72.     Memo2: TMemo;
  73.     Memo3: TMemo;
  74.     ReSizerPanel2: TReSizerPanel;
  75.     Label11: TLabel;
  76.     BitBox1: TBitBox;
  77.     Button10: TButton;
  78.     Invoice1: TInvoice;
  79.     AboutBox1: TAboutBox;
  80.     Button9: TButton;
  81.     Edit5: TEdit;
  82.     Label12: TLabel;
  83.     Label13: TLabel;
  84.     Edit6: TEdit;
  85.     Label14: TLabel;
  86.     RadioGroup1: TRadioGroup;
  87.     Button11: TButton;
  88.     PropertyViewer1: TPropertyViewer;
  89.     Label15: TLabel;
  90.     CheckBox1: TCheckBox;
  91.     procedure FormCreate(Sender: TObject);
  92.     procedure Edit1Change(Sender: TObject);
  93.     procedure SpeedButton1Click(Sender: TObject);
  94.     procedure BitBox1Change(Sender: TObject);
  95.     procedure Button1Click(Sender: TObject);
  96.     procedure Button2Click(Sender: TObject);
  97.     procedure Button3Click(Sender: TObject);
  98.     procedure Button4Click(Sender: TObject);
  99.     procedure Button5Click(Sender: TObject);
  100.     procedure Button6Click(Sender: TObject);
  101.     procedure Button7Click(Sender: TObject);
  102.     procedure Button8Click(Sender: TObject);
  103.     procedure Button10Click(Sender: TObject);
  104.     procedure Button9Click(Sender: TObject);
  105.     procedure RadioGroup1Click(Sender: TObject);
  106.     procedure Button11Click(Sender: TObject);
  107.     procedure CheckBox1Click(Sender: TObject);
  108.   private
  109.     { Private declarations }
  110.   public
  111.     { Public declarations }
  112.   end;
  113.  
  114. const
  115.   BoolString: array[False..True] of string[5] = ('FALSE','TRUE');
  116.  
  117. var
  118.   tPack2Form: TtPack2Form;
  119.  
  120. implementation
  121.  
  122. {$R *.DFM}
  123.  
  124. {-----------------------------------------------------------------------------------------}
  125. { FORM CODE                                                                               }
  126. {-----------------------------------------------------------------------------------------}
  127.  
  128. procedure TtPack2Form.FormCreate(Sender: TObject);
  129. begin
  130.   TabbedNoteBook1.PageIndex:= 0;
  131.   CheckBox1.Checked:= DebugControl1.Enabled;
  132.  
  133.   with NovellGrid do begin
  134.     ColCount:=2;
  135.     ColWidths[0]:=120;
  136.     ColWidths[1]:=200;
  137.     Width:=320+GridLineWidth;
  138.     RowCount:=1+6;
  139.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  140.     cells[0,0]:='Property';
  141.     cells[1,0]:='Value';
  142.  
  143.     cells[0,1]:='ConnectID';
  144.     cells[0,2]:='ConnectNumber';
  145.     cells[0,3]:='ServerName';
  146.     cells[0,4]:='LoginName';
  147.     cells[0,5]:='FullName';
  148.     cells[0,6]:='LoginTime';
  149.  
  150.     with NetWareUserInfo1 do begin
  151.       cells[1,1]:=inttostr(ConnectID);
  152.       cells[1,2]:=inttostr(ConnectNumber);
  153.       cells[1,3]:=ServerName;
  154.       cells[1,4]:=LoginName;
  155.       cells[1,5]:=FullName;
  156.       cells[1,6]:=LoginTime +' (FORMAT??)';
  157.       end;
  158.     end;
  159.  
  160.   with WindowsGrid do begin
  161.     ColCount:=2;
  162.     ColWidths[0]:=120;
  163.     ColWidths[1]:=200;
  164.     Width:=320+GridLineWidth;
  165.     RowCount:=1+4;
  166.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  167.     cells[0,0]:='Property';
  168.     cells[1,0]:='Value';
  169.     cells[0,1]:='LoginName';
  170.     cells[0,2]:='CompanyName';
  171.     cells[0,3]:='WindowsPath';
  172.     cells[0,4]:='SaverDelay';
  173.  
  174.     with WindowsUserInfo1 do begin
  175.       cells[1,1]:=UserName;
  176.       cells[1,2]:=CompanyName;
  177.       cells[1,3]:=WindowsPath;
  178.       cells[1,4]:=inttostr(SaverDelay);
  179.       end;
  180.     end;
  181.  
  182.   with BDEGrid do begin
  183.     ColCount:=2;
  184.     ColWidths[0]:=120;
  185.     ColWidths[1]:=200;
  186.     Width:=320+GridLineWidth;
  187.     RowCount:=1+6;
  188.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  189.     cells[0,0]:='Property';
  190.     cells[1,0]:='Value';
  191.     cells[0,1]:='UserName';
  192.     cells[0,2]:='NetType';
  193.     cells[0,3]:='NetProtocol';
  194.     cells[0,4]:='NetShare';
  195.     cells[0,5]:='LocalShare';
  196.     cells[0,6]:='IniFile';
  197.     cells[0,7]:='LangDriver';
  198.  
  199.     with BDEUserInfo1 do begin
  200.       cells[1,1]:=UserName;
  201.       cells[1,2]:=NetType;
  202.       cells[1,3]:=inttostr(NetProtocol);
  203.       cells[1,4]:=BoolString[NetShare];
  204.       cells[1,5]:=BoolString[LocalShare];
  205.       cells[1,6]:=IniFile;
  206.       cells[1,7]:=LangDriver;
  207.       end;
  208.     end;
  209.  
  210.   Edit1.Text:=inttostr(BitBox1.Numeric);
  211.  
  212.   Edit2.Text:=Application.Title;
  213.   Edit3.Text:='Caption';
  214.   Edit4.Text:=Caption;
  215.   Button3.Click; {to save}
  216.  
  217. end;
  218.  
  219.  
  220. procedure TtPack2Form.SpeedButton1Click(Sender: TObject);
  221. begin
  222.   Close;
  223. end;
  224.  
  225. procedure TtPack2Form.BitBox1Change(Sender: TObject);
  226. begin
  227.   Edit1.Text:=inttostr(BitBox1.Numeric);
  228. end;
  229.  
  230. procedure TtPack2Form.Edit1Change(Sender: TObject);
  231. begin
  232.   BitBox1.Numeric:=StrToIntDef(Edit1.Text,0);
  233. end;
  234.  
  235.  
  236. procedure TtPack2Form.Button1Click(Sender: TObject);
  237. begin
  238.   Splashscreen1.Execute; {uses (customizable) component residing on form}
  239. end;
  240.  
  241. procedure TtPack2Form.Button2Click(Sender: TObject);
  242. begin
  243.   with TSplashScreen.Create(self) do
  244.     free; {instantiates and releases form loader}
  245. end;
  246.  
  247. procedure TtPack2Form.Button3Click(Sender: TObject);
  248. begin
  249.   with IniFileLink1 do begin {name/path blank by default point to exe dir/name}
  250.     Section:=Edit2.Text;
  251.     Entry:=Edit3.Text;
  252.     StringValue:=Edit4.Text; {this writes it as a string}
  253.     end;
  254. end;
  255.  
  256. procedure TtPack2Form.Button4Click(Sender: TObject);
  257. begin
  258.   with IniFileLink1 do begin {name/path blank by default point to exe dir/name}
  259.     Section:=Edit2.Text; {you don't have to do this usually. this is a demo}
  260.     Entry:=Edit3.Text;
  261.     Edit4.Text:=StringValue; {this reads it as a string}
  262.     end;
  263. end;
  264.  
  265. procedure TtPack2Form.Button5Click(Sender: TObject);
  266. begin
  267.   AboutBox;   {uses code in toolproc to run about box.
  268.                consider moving the code below into there as well.}
  269. end;
  270.  
  271. procedure TtPack2Form.Button6Click(Sender: TObject);
  272. begin
  273.   with LoginDialog1 do begin
  274.     Execute;
  275.     if not PassWordOk then
  276.       raise Exception.Create('PASSWORD NOT SUPPLIED.. TRY ''TPACK''');
  277.     end;
  278.  
  279. end;
  280.  
  281. procedure TtPack2Form.Button7Click(Sender: TObject);
  282. const
  283.   i:longint=0;
  284. begin
  285.   WorkingMsg1.Execute;
  286.   while WorkingMsg1.Active do begin
  287.     inc(i);
  288.     Application.Hint:='Sample Process running; '+inttostr(i);
  289.     Application.OnHint(Sender);
  290.     end;
  291. end;
  292.  
  293. procedure TtPack2Form.Button8Click(Sender: TObject);
  294. begin
  295.   ErrorDialog1.Test:=true;
  296. end;
  297.  
  298. procedure TtPack2Form.Button10Click(Sender: TObject);
  299. begin
  300.   Invoice1.Execute;
  301. end;
  302.  
  303. procedure TtPack2Form.Button9Click(Sender: TObject);
  304. begin
  305.   PropertyViewer1.Persistent:=tPack2Form;
  306.   PropertyViewer1.Execute;
  307. end;
  308.  
  309. procedure TtPack2Form.RadioGroup1Click(Sender: TObject);
  310. begin
  311.   with TRadioGroup(Sender) do
  312.     case ItemIndex of
  313.      -1: exit;
  314.       0: begin
  315.          Edit5.Text:='dir';
  316.          Edit6.Text:='/p';
  317.          end;
  318.       1: begin
  319.          Edit5.Text:='notepad';
  320.          Edit6.Text:='!readme';
  321.          end;
  322.       2: begin
  323.          Edit5.Text:='tpDll';
  324.          Edit6.Text:='AboutBox';
  325.          end;
  326.     end;
  327. end;
  328.  
  329. procedure TtPack2Form.Button11Click(Sender: TObject);
  330. var
  331.   s:TGenericShell;
  332. begin
  333.   with RadioGroup1 do
  334.     case ItemIndex of
  335.      -1: exit;
  336.       0: s:=TDosShell.Create(Owner);
  337.       1: s:=TWindowsShell.Create(Owner);
  338.       2: s:=TDLLShell.Create(Owner);
  339.       end;
  340.   with s do try
  341.     Flags:=Flags+[shlMsgTillReady];
  342.     run(edit5.Text,edit6.Text);
  343.   finally
  344.     free;
  345.     end;
  346. end;
  347.  
  348. procedure TtPack2Form.CheckBox1Click(Sender: TObject);
  349. begin
  350.   DebugControl1.Enabled:= CheckBox1.Checked;
  351. end;
  352.  
  353. end.
  354.